#ifndef CHAT_MESSAGE_IN_MEMORY_H
#define CHAT_MESSAGE_IN_MEMORY_H

#include <string>
#include "SingleClass.h"
#include <unordered_map>
#include "spin_lock.h"

class message_item{
public:
    message_item(const std::string &from_email,const std::string &to_email,const int& msg_type,const std::string &msg_id,const std::string msg_data){
        this->from_email=from_email;
        this->to_email=to_email;
        this->msg_type=msg_type;
        this->msg_id=msg_id;
        this->msg_data=msg_data;
    }

    std::string from_email;
    std::string to_email;
    int msg_type;
    std::string msg_id;
    std::string msg_data;


};

class message_list:public SingleClass<message_list>{

public:
    //一些基本操作---返回值无效
    bool insert_message_item(const std::string &msg_id,message_item * item);
    bool erase_message_item(const std::string &msg_id);

    


private:
    friend class SingleClass<message_list>;
    message_list()=default;
    std::unordered_map<std::string,message_item *> message_map;

    spin_lock spin_mtx;



};




#endif